package com.sxkiler.demo.test;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;

import java.util.Properties;

public class NameServiceUtil {
    /**
     * 获取注册中心地址
     * @return
     * @throws NacosException
     */
    public static NamingService getNamingService() throws NacosException {
        String serverAddr  = "127.0.0.1:8848";
        String namespace = "public";
        Properties properties = new Properties();
        properties.setProperty("serverAddr", serverAddr);
        properties.setProperty("namespace", namespace);
        NamingService naming = NamingFactory.createNamingService(properties);
        return naming;
    }
}
